<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('bills', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->comment('关联用户');
            $table->unsignedBigInteger('bill_type_id')->comment('账单类型');
            $table->decimal('amount', 12, 2)->comment('账单金额（单位：元）');
            $table->dateTime('bill_time')->comment('账单发生时间');
            $table->text('remark')->nullable()->comment('账单备注');
            $table->timestamps();
            $table->foreign('bill_type_id')->references('id')->on('bill_types');
            $table->foreign('user_id')->references('id')->on('users');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('bills');
    }
};
